package com.bjesc_b2c.app.appraiset.adapter;

import android.content.Context;
import android.text.TextUtils;

import com.bjesc_b2c.app.appraiset.R;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.imagepipeline.core.ImagePipeline;

import java.util.List;

import app.pinggushi.bjesc.com.baserecyclerview.adapter.CommonAdapter;
import app.pinggushi.bjesc.com.baserecyclerview.adapter.base.ViewHolder;
import master_bean.CarSourcePhotoBean;

/**
 * Created by lenovo on 2017/2/24.
 * 设置网格图片的Adapter
 */

public class CarSourcePhotoAdapter extends CommonAdapter<CarSourcePhotoBean> {
    public CarSourcePhotoAdapter(Context context, int layoutId, List<CarSourcePhotoBean> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convertView(ViewHolder holder, CarSourcePhotoBean bean, int position) {
            holder.setText(R.id.tv_photo_name, bean.getPhotoName());
            holder.setIsRecyclable(false);// //强制关闭复用   或者显示默认图片
            if (bean.getPhotoName().equals("更多")){
                holder.setVisible(R.id.slanTv, false);
            }
            ImagePipeline imagePipeline = Fresco.getImagePipeline();
            imagePipeline.clearCaches();
            if(!TextUtils.isEmpty(bean.getPhoto())){
                if(bean.getPhoto().contains("http")){
                    holder.setFrescoUrl(R.id.fresc_car_source_photo,bean.getPhoto(),true);
                    holder.setVisible(R.id.slanTv, false);
                }else{
                    holder.setFrescoFile(R.id.fresc_car_source_photo,bean.getPhoto(),true);
                    holder.setVisible(R.id.slanTv, true);
                }
        }

    }
}
